package com.nf.controller.home;

import com.google.gson.Gson;
import com.nf.controller.BaseServlet;
import com.nf.dao.FilmInfoDao;
import com.nf.dao.impl.FilmInfoDaoImpl;
import com.nf.entity.FilmInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * 编写servlet ，实现根据上映状态、影片类型和影片来源国家 模糊查询电影
 */
@WebServlet("/api/SelectIsShowFilmsByLikeServlet.do")
public class SelectIsShowFilmsByLikeServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int status= Integer.parseInt(req.getParameter("status"));
        String condType=req.getParameter("condType");
        String condCountry=req.getParameter("condCountry");

        FilmInfoDao dao=new FilmInfoDaoImpl();
        List<FilmInfo> list=dao.selectIsShowByLike(status,condType,condCountry);

        resp.setContentType("application/json;charset=utf-8");
        PrintWriter out = resp.getWriter();

        out.print(new Gson().toJson(successJson(list)));
        out.flush();
        out.close();
    }
}
